<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr1=["北京","上海","广州",["白云区","黄浦区"],{uname:"张三",age:21,school:{name:"积云教育",address:"海淀"}}]
        let arr2=[]
        function xyh(arr1,arr2){ //arr1：旧数组 arr2:新数组
            for(k in arr1){
                if(arr1[k]instanceof Array){
                    // 数组
                    arr2[k] = []
                    xyh(arr2[k],arr1[k])
                }else if (arr1[k] instanceof Object){
                    // 对象
                    arr2[k]={}
                    xyh(arr2[k],arr1[k])
                }else{
                    // 字符串
                    arr2[k] = arr1[k]
                }
            }
        }
        xyh(arr2,arr1)
        // arr2[4].school.name = "jiyunjiaoyv"
        // console.log("arr2",arr2);
        console.log("arr1",arr1);
    </script>
</body>
</html>